import sys
import collections
import math
t=int(input())
n = 4
binary = format(n, 'b')
n = int(binary, 2)
def CountFrequency(my_list):
freq = {}
for item in my_list:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
return freq
for i in range(t):
list = input().rsplit(" ")
n = int(list[0])
x = int(list[1])
ans=0
i = 1
ji = 0
while(ji*ji<=n):
ji=ji+1
ji=ji-1
while(i*i<=n and i<=x):
j = 1
while(j*j<=n):
p1 = (n-i*j)//(i+j)
p1 = max(0,p1)
p2 = x-i-j
p2=max(0,p2)
p2=min(p1,p2)
ans=ans+p2
if(p2>=ji):
ans=ans+(p2-ji)*2
j=j+1
i=i+1
print(ans)
1143B - Nirvana | 1285A - Mezo Playing Zoma |
919B - Perfect Number | 894A - QAQ |
1551A - Polycarp and Coins | 313A - Ilya and Bank Account |
1469A - Regular Bracket Sequence | 919C - Seat Arrangements |
1634A - Reverse and Concatenate | 1619C - Wrong Addition |
1437A - Marketing Scheme | 1473B - String LCM |
1374A - Required Remainder | 1265E - Beautiful Mirrors |
1296A - Array with Odd Sum | 1385A - Three Pairwise Maximums |
911A - Nearest Minimums | 102B - Sum of Digits |
707A - Brain's Photos | 1331B - Limericks |
305B - Continued Fractions | 1165B - Polycarp Training |
1646C - Factorials and Powers of Two | 596A - Wilbur and Swimming Pool |
1462B - Last Year's Substring | 1608B - Build the Permutation |
1505A - Is it rated - 2 | 169A - Chores |
765A - Neverending competitions | 1303A - Erasing Zeroes |